package com.kx.yooli.kx.wechat;

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * main class
 * @author john_sqwen
 * @date 2024-03-19
 */
@SpringBootApplication
@EnableEncryptableProperties
@MapperScan(basePackages = "com.kx.yooli.kx.wechat.mapper.*")
public class WechatApplication {
    private final static Logger log = LoggerFactory.getLogger(WechatApplication.class);
    /**
     *  spring boot main
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication app=new SpringApplication(WechatApplication.class);
        ConfigurableApplicationContext application=app.run(args);
        //ConfigurableApplicationContext application=SpringApplication.run(Knife4jSpringBootDemoApplication.class, args);
        Environment env = application.getEnvironment();
        try {
            log.info("\n----------------------------------------------------------\n\t" +
                            "Application '{}' is running! Access URLs:\n\t" +
                            "Local: \t\thttp://localhost:{}\n\t" +
                            "External: \thttp://{}:{}\n\t"+
                            "Doc: \thttp://{}:{}/doc.html\n"+
                            "----------------------------------------------------------",
                    env.getProperty("spring.application.name"),
                    env.getProperty("server.port"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"));
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }

    }
}
